import { connect } from "dva"
import SearchBar from "../StudentSearchBar"

const mapStateToProps = state=>({
    key:state.students.condition.key,
    sex: state.students.condition.sex
})

const matDispatchToProps = dispatch =>({
    onSearch(newCondition){
        newCondition.page = 1;
        dispatch({
            type: "students/setCondition",
            payload: newCondition
        })
        dispatch({
            type: "students/fetchStudents",
        })
    }
})

export default connect(mapStateToProps, matDispatchToProps)(SearchBar)